/*
 * @文件描述: 首页
 * @公司: 山东大学信息学院
 * @作者: 李洪文
 * @Date: 2019-05-29 15:45:14
 * @LastEditors: 李洪文
 * @LastEditTime: 2020-10-10 17:59:07
 */
import React from 'react';
import {SafeAreaView, ScrollView, View, Image, Text} from 'react-native';
import {Carousel} from 'teaset';
import NavigationService from '@/NavigationService';
import Icon from 'react-native-vector-icons/AntDesign';
import SearchHeader from '@/components/SearchHeader';
import GrayBar from '@/components/GrayBar';
import {colors} from '@/config';
import {Button} from 'native-base';
import {styles} from './style';

export default function Home() {
  const testAPI = () => {
    API.test.hello
      .request({
        title: 'title222',
        author: 'author111'
      })
      .then(() => {
        console.warn('成功！')
      })
      .catch((e) => console.warn(e));
  };
  return (
    <SafeAreaView style={{flex: 1}}>
      <SearchHeader
        left={
          <Icon
            color={colors.black}
            onPress={() => NavigationService.navigate('QrCode')}
            name="qrcode"
            size={24}
          />
        }
        right={
          <Icon color={colors.black} name="message1" size={24} />
        }></SearchHeader>
      <ScrollView>
        <Carousel style={{height: 187}} control={true}>
          <Image
            style={styles.banner}
            source={require('@/assets/image/home/banner/banner1.png')}
          />
          <Image
            style={styles.banner}
            source={require('@/assets/image/home/banner/banner2.png')}
          />
          <Image
            style={styles.banner}
            source={require('@/assets/image/home/banner/banner3.png')}
          />
        </Carousel>
        <View style={styles.notice}>
          <Icon
            name="bells"
            color={colors.black}
            size={16}
            style={styles.noticeIcon}
          />
          <Text style={styles.textColor}>本月公告内容如下：黄瓜33元</Text>
        </View>

        <Button full onPress={() => NavigationService.navigate('OrderDetail')}>
          <Text style={{color: 'white'}}>测试按钮，点击后打开订单详情</Text>
        </Button>

        <Button full onPress={testAPI} style={{marginTop: 20}}>
          <Text style={{color: 'white'}}>测试API</Text>
        </Button>
        <ScrollView horizontal={true}>
          <View style={styles.vegetableWrap}></View>
        </ScrollView>

        <GrayBar />
      </ScrollView>
    </SafeAreaView>
  );
}
